package dao.mapper.auth;

import model.auth.Resources;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.mybatis.spring.annotation.Mapper;

@Mapper("auth.ResourcesCrudMapper")
public interface ResourcesCrudMapper {

	@Select("select seq_a_resources.nextval from dual")
	long selectKey();
	
	@Insert("insert into a_resources (id, resname, restype, priority, reslink, resdesc, enabled, issys) values" +
			" (#{m.id}, #{m.resname}, #{m.restype}, #{m.priority}, #{m.reslink}, #{m.resdesc}, #{m.enabled}, #{m.issys})")
	int insert(@Param("m") Resources model);
	
	@Select("select * from a_resources where id=#{id} ")
	Resources getById(@Param("id") Long id);

	@Select("select * from a_resources where id=#{id} and enabled=#{enabled}")
	Resources getValidById(@Param("id") Long id, @Param("enabled") Integer enabled);
	
	@Delete("delete from a_resources where id=#{id}")
	int deleteById(@Param("id") Long id);
	
}
